package com.quectel.core.module.forum.entity.mongo;

import com.quectel.core.constants.MongoCollectionConstants;
import com.quectel.util.client.mongo.MongoBaseModel;
import lombok.Data;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.index.TextIndexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.util.Date;
import java.util.List;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/5/8 15:52
 * @description 帖子
 */
@Data
@Document(MongoCollectionConstants.FORUM_POST)
@CompoundIndex(name = "idx_tenant_village", def = "{'tenantId': 1,'villageId': 1}", background = true)
@CompoundIndex(name = "idx_tenant_city", def = "{'tenantId': 1,'cityCode': 1}", background = true)
@CompoundIndex(name = "idx_tenant_author", def = "{'tenantId': 1,'authorId': 1}", background = true)
@CompoundIndex(name = "idx_top_id", def = "{'topFlag': -1,'_id': -1}", background = true)
public class ForumPostModel implements MongoBaseModel {
    /**
     * id
     */
    @MongoId
    private Long id;

    /**
     * 租户id
     */
    private Long tenantId;

    /**
     * 城市id
     */
    private String cityCode;

    /**
     * 可见小区id
     */
    private Long villageId;

    /**
     * 作者id
     */
    private Long authorId;

    /**
     * 所属类别
     */
    private Byte type;

    /**
     * 绑定话题
     */
    @Indexed(name = "idx_topics", background = true)
    private List<Long> topics;

    /**
     * 内容
     */
    private String content;

    /**
     * 分词后的数据
     */
    @TextIndexed
    private String contentText;

    /**
     * 图片列表
     */
    private List<String> imageUrls;

    /**
     * 点赞数量
     */
    private Integer likeCount = 0;

    /**
     * 评论数量
     */
    private Integer commentCount = 0;

    /**
     * 分享数量
     */
    private Integer shareCount = 0;

    /**
     * 是否置顶 1置顶0非置顶
     */
    private Byte topFlag = 0;

    /**
     * 是否其他小区可见 1可见0非可见
     */
    @Indexed(name = "idx_visible", background = true)
    private Byte visibleFlag = 1;

    /**
     * 删除标识
     */
    @Indexed(name = "idx_delete", background = true)
    private Byte deletedFlag = 0;

    /**
     * 创建时间
     */
    @Indexed(name = "idx_publish_time", background = true)
    private Date publishTime;

    /**
     * 编辑时间
     */
    private Date editTime;


}
